<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <title>
        修改设计师
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/css/x-admin.css" media="all">
</head>

<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="link" class="layui-form-label">
                <span class="x-red">*</span>设计师图片
            </label>
            <div class="layui-input-inline">
                <div class="site-demo-upbar">
                    <input type="file" name="upfile" class="layui-upload-file" id="test">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="link" class="layui-form-label">
                <span class="x-red">*</span>图片预览
            </label>
            <div class="layui-input-inline" id="productImage">
                <div class="site-demo-upbar">

                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="bigTitle" class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="bigTitle" name="bigTitle" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="title1" class="layui-form-label">
                <span class="x-red">*</span>从业经验
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="title1" name="title1"
                       autocomplete="off" class="layui-input" required="" lay-verify="required">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="title2" class="layui-form-label">
                <span class="x-red"></span>案例作品
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="title2" name="title2"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="title3" class="layui-form-label">
                <span class="x-red"></span>职位
            </label>
            <div class="layui-input-inline">
                <input type="text"  id="title3" name="title3"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="jianjie" class="layui-form-label">
                <span class="x-red"></span>设计师简介
            </label>
            <div class="layui-input-inline">
                <textarea id="jianjie"name="jianjie"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="wztitle" class="layui-form-label">
                <span class="x-red">*</span>设计师分类
            </label>
            <div class="layui-input-inline">
                <div class="layui-input-block">
                    <input type="radio" name="sjStyle" value="0" title="软装设计师">
                    <input type="radio" name="sjStyle" value="1" title="主创设计师">
                </div>
            </div>
        </div>


        <br><br>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                修改
            </button>
        </div>
    </form>

    <div class="x-body" id="div3">

    </div>



</div>
<script src="/js/jquery-2.2.4.min.js" charset="utf-8">
</script>
<script src="/lib/layui/layui.js" charset="utf-8">
</script>
<script src="/js/x-layui.js" charset="utf-8">
</script>
<script src="/js/vue.js" charset="utf-8">
</script>
<script type="text/javascript" src="/js/wangEditor.js"></script>
<script>

    var E = window.wangEditor
    var editor = new E('#div2');
    editor.customConfig.pasteIgnoreImg = false;
    editor.customConfig.uploadImgShowBase64 = true;

    editor.customConfig.uploadImgServer = '/upload';
    editor.customConfig.uploadFileName = 'file';

    editor.customConfig.menus = [
        'bold',  // 粗体
        'fontSize',  // 字号
        'italic',  // 斜体
        'underline',  // 下划线
        'strikeThrough',  // 删除线
        'foreColor',  // 文字颜色
        'backColor',  // 背景颜色
        'code',  // 插入代码
        'link',  // 插入链接
        'justify',  // 对齐方式
        'quote',  // 引用
        'emoticon',  // 表情
        'image',  // 插入图片
        'table',  // 表格
        'video',  // 插入视频
        'undo'  // 撤销

    ]


    editor.customConfig.onfocus = function () {

    }

    editor.customConfig.onblur = function (html) {

    }

    editor.create();

    $(document).ready(function () {
        loadShejishi();
    });

    var sjsId = '[[${sjsInfo.id}]]';
    var sjsPicUrl = '[[${sjsInfo.picUrl}]]';
    var anliNum = '[[${sjsInfo.valueCase1}]]';
    var jingyan = '[[${sjsInfo.valueCase2}]]';
    var zhiwei = '[[${sjsInfo.valueCase3}]]';
    var realName = '[[${sjsInfo.picTitle}]]';
    var sjsType = '[[${sjsInfo.valueCase4}]]';
    var jianjie = '[[${sjsInfo.valueText}]]';
    var imageFilename = '';
    var picUrls = '[[${picUrl}]]';

    function loadShejishi() {
        imageFilename = sjsPicUrl;
        $('#bigTitle').val(realName);
        $('#title1').val(jingyan + '年');
        $('#title2').val(anliNum);
        $('#title3').val(zhiwei);
        $('#jianjie').val(jianjie);
        $('input[name=sjStyle][value='+sjsType+']').attr("checked",true);
        $('#productImage').html('<img src="'+ picUrls + sjsPicUrl +'" width="100px" height="40px">');
    }




    layui.use(['form','layer', 'upload'], function(){
        $ = layui.jquery;
        var form = layui.form();
        var layer = layui.layer;

        layui.upload({
            url: '/bo/homePicture/upload.html', //上传接口
            success: function(res){ //上传成功后的回调
                imageFilename = res.data.filename;
                $('#productImage').html('<img src="'+ res.data.imageUrl +'" width="100px" height="40px">');
            }
        });

        var featurePro = [];
        //监听提交
        form.on('submit(add)', function(data){

//            var context = editor.txt.html();

            //发异步，把数据提交给服务器
            $.ajax({
                url: '/bo/modifyShejishi.html',
                type: 'POST', //GET
                async: true,    //或false,是否异步
                data: {
                    id:sjsId,
                    realName : $('#bigTitle').val(),
                    jingyan : $('#title1').val(),
                    anliNum : $('#title2').val(),
                    zhiwei : $('#title3').val(),
                    picUrl : imageFilename,
                    sjStyle : $("input[name='sjStyle']:checked").val(),
                    jianjie:$('#jianjie').val()
                },
                timeout: 10000,    //超时时间
                dataType: 'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                success: function (ajaxData, textStatus, jqXHR) {
                    if (1000 != ajaxData.code) {
                        layer.alert(ajaxData.message, {icon: 5},function (index) {
                            layer.close(index);
                        });
                        return;
                    }

                    layer.alert('修改成功', {icon: 6},function (index) {
                        layer.close(index);
                        window.location.href = "/bo/toShejishiList.html";
                    });


                }
            });

            return false;
        });
    });


</script>
<script>

</script>
</body>

</html>